﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="~/css/table.css" rel="stylesheet" />
    <link href="~/css/cwcalendar.css" rel="stylesheet" />
    <script src="~/javascript/comm/comm.js"></script>
    <script src="~/javascript/comm/list.js"></script>
    <script src="~/javascript/calendar-ch.js"></script>
    <script src="~/javascript/jquery-1.7.2.js"></script>
    <script src="~/javascript/locate.js"></script>
    <script src="~/javascript/select.js"></script>

    <script type="text/javascript">
        window.onload = check;
        function tick() {
            var now = new Date();
            var hours, minutes, seconds, noon;
            var intHours, intMinutes, intSeconds;
            intHours = now.getHours();
            intMinutes = now.getMinutes();
            intSeconds = now.getSeconds();
            if (intHours < 24) {
                hours = intHours + ":";
                noon = "A.M.";
            } else {
                intHours = intHours - 24;
                hours = intHours + ":";
                noon = "P.M.";
            }
            if (intMinutes < 10) {
                minutes = "0" + intMinutes + ":";
            } else {
                minutes = intMinutes + ":";
            }
            if (intSeconds < 10) {
                seconds = "0" + intSeconds + " ";
            } else {
                seconds = intSeconds + " ";
            }
            timeString = hours + minutes + seconds;
            var now = new Date();
            document.getElementById("regist_time").value = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate() + " " + timeString;
            window.setTimeout("tick();", 1000);
        }

        //load事件
        function check() {
            //获得系统当前时间的方法
            tick();
        }
    </script>
</head>
<body>
    <div id="app">
        <form method="post" id="form1">
            <table width="100%">
                <tr>
                    <td>
                        <font color="black">您正在做的业务是：人力资源--招聘管理--职位发布管理--职位发布登记 </font>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <input type="button" v-on:click="Add()" value="提交" class="BUTTON_STYLE1"
                               onclick="mysubmit();">
                        <input type="reset" value="清除" class="BUTTON_STYLE1">
                    </td>
                </tr>
            </table>
            <table width="100%" border="1" cellpadding=0 cellspacing=1
                   bordercolorlight=#848284 bordercolordark=#eeeeee
                   class="TABLE_STYLE1">
                <tr>
                    <td class="TD_STYLE1" width="11%">
                        I级机构
                    </td>
                    <td width="14%" class="TD_STYLE2">
                        <input hidden="hidden" id="first_kind_name" name="first_kind_name" v-model="first_kind_name" />
                        <select name="first_kind_id" id="first_kind_id" v-model="first_kind_id" class="INPUT_STYLE1">
                            <option v-for="(item,index) in onelist" v-on:click="GetfirstId(item.first_kind_id)" :value="item.first_kind_id">{{item.first_kind_name}}</option>
                        </select>
                    </td>
                    <td width="11%" class="TD_STYLE1">
                        II级机构
                    </td>
                    <td width="14%" class="TD_STYLE2">
                        <input hidden="hidden" id="second_kind_name" name="second_kind_name" v-model="second_kind_name" />
                        <select name="second_kind_id" id="second_kind_id" v-model="second_kind_id" class="INPUT_STYLE1">
                            <option v-for="(item,index) in secondlist" v-on:click="GetsecondId(item.second_kind_id)" :value="item.second_kind_id">{{item.second_kind_name}}</option>
                        </select>
                    </td>
                    <td width="11%" class="TD_STYLE1">
                        III级机构
                    </td>
                    <td class="TD_STYLE2">
                        <input hidden="hidden" id="third_kind_name" name="third_kind_name" v-model="third_kind_name" />
                        <select name="third_kind_id" id="third_kind_id" v-model="third_kind_id" class="INPUT_STYLE1">
                            <option v-for="(item,index) in thirdlist" :value="item.third_kind_id">{{item.third_kind_name}}</option>
                        </select>

                    </td>
                    <td width="11%" class="TD_STYLE1">
                        招聘类型
                    </td>
                    <td class="TD_STYLE2" colspan="2">
                        <select name="engage_type" id="engage_type" class="SELECT_STYLE1" v-model="engage_type">
                            <option value="">--请选择--</option>

                            <option value="校园招聘">校园招聘</option>

                            <option value="社会招聘">社会招聘</option>

                        </select>

                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        职位分类
                    </td>
                    <td class="TD_STYLE2">
                        <input hidden="hidden" id="major_kind_name" name="major_kind_name" v-model="major_kind_name" />
                        <select name="major_kind_id" id="major_kind_id" v-model="major_kind_id" class="INPUT_STYLE1">
                            <option v-for="(item,index) in majorKindlist" v-on:click="Getmajor(item.major_kind_id)" :value="item.major_kind_id">{{item.major_kind_name}}</option>
                        </select>
                    </td>
                    <td class="TD_STYLE1">
                        职位名称
                    </td>
                    <td class="TD_STYLE2">
                        <input hidden="hidden" id="major_name" name="major_name" v-model="major_name" />
                        <select name="major_id" id="major_id" v-model="major_id" class="INPUT_STYLE1">
                            <option v-for="(item,index) in majorlist" :value="item.major_id">{{item.major_name}}</option>
                        </select>
                    </td>
                    <td class="TD_STYLE1">
                        招聘人数
                    </td>
                    <td class="TD_STYLE2">
                        <input type="text" name="human_amount" id="human_amount" v-model="human_amount"  class="INPUT_STYLE2">
                    </td>
                    <td class="TD_STYLE1">
                        截止日期
                    </td>
                    <td class="TD_STYLE2">
                        <input type="date" name="deadline"  v-model="deadline" class="INPUT_STYLE2" id="deadline">
                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        登记人
                    </td>
                    <td class="TD_STYLE2">
                        <input type="text" name="register" value="@ViewData["name"]"  v-model="register" class="INPUT_STYLE2">
                    </td>
                    <td class="TD_STYLE1">
                        登记时间
                    </td>
                    <td class="TD_STYLE2">

                        <input type="text" name="regist_time"
                               id="regist_time" readonly="readonly" v-model="regist_time"
                               class="INPUT_STYLE2">
                    </td>

                    <td>&nbsp; </td>
                    <td>&nbsp; </td>
                    <td>&nbsp; </td>
                    <td>&nbsp; </td>

                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        职位描述
                    </td>
                    <td class="TD_STYLE2" colspan="8">
                        <textarea name="major_describe" id="major_describe"  v-model="major_describe" rows="4" cols="80" class="TEXTAREA_STYLE1"></textarea>
                    </td>

                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        招聘要求
                    </td>
                    <td class="TD_STYLE2" colspan="8">
                        <textarea name="engage_required" id="engage_required" v-model="engage_required"  rows="4" cols="80" class="TEXTAREA_STYLE1"></textarea>
                    </td>

                </tr>
            </table>
        </form>
        </div>
</body>
</html>

<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            onelist: [],
            secondlist: [],
            thirdlist: [],
            majorKindlist: [],
            majorlist:[],
            first_kind_id: "",
            first_kind_name: "",
            second_kind_id: "",
            second_kind_name: "",
            third_kind_id: "",
            third_kind_name: "",
            engage_type: "",
            major_kind_id:"",
            major_kind_name: "",
            major_id: "",
            major_name: "",
            human_amount: "",
            engage_type: "",
            deadline: "",
            register: "",
            regist_time: "",
            major_describe: "",
            engage_required:"",
        },
        methods: {
            load: function () {
                var t = this;
                $.ajax({
                    url: "/position/GetAll",
                    type: "Post",
                    success: function (msg) {
                        var dts = eval("(" + msg + ")");
                        t.onelist = dts["first"];
                        t.secondlist = dts["second"];
                        t.thirdlist = dts["third"];
                        t.majorKindlist = dts["major_kind"];
                        t.majorlist = dts["major"];
                    }
                })
            },
            GetfirstId: function (id) {
                var t = this;
                $.ajax({
                    url: "/position/GetfirstId",
                    type: "Post",
                    data: "id=" + id,
                    success: function (msg) {
                        var dts = eval(msg);
                        t.secondlist = dts;
                    }
                })
            },
            GetsecondId: function (id) {
                var t = this;
                $.ajax({
                    url: "/position/GetsecondId",
                    type: "Post",
                    data: "id=" + id,
                    success: function (msg) {
                        var dts = eval(msg);
                        t.thirdlist = dts;
                    }
                })
            },
            Getmajor: function (id) {
                var t = this;
                $.ajax({
                    url: "/position/Getmajor",
                    type: "Post",
                    data: "id=" + id,
                    success: function (msg) {
                        var dts = eval(msg);
                        t.majorlist = dts;
                    }
                })
            },
            Add: function () {
                var first_id = $("#first_kind_id option:selected").text();
                $("#first_kind_name").val(first_id);
                var second_id = $("#second_kind_id option:selected").text();
                $("#second_kind_name").val(second_id);
                var third_id = $("#third_kind_id option:selected").text();
                $("#third_kind_name").val(third_id);
                var major_kind_id = $("#major_kind_id option:selected").text();
                $("#major_kind_name").val(major_kind_id);
                var major_id = $("#major_id option:selected").text();
                $("#major_name").val(major_id);

                
                var first_kind_name = $("#first_kind_id option:selected").text();
                var second_kind_name = $("#second_kind_id option:selected").text();
                var third_kind_name = $("#third_kind_id option:selected").text();
                var major_kind_name = $("#major_kind_id option:selected").text(); 
                var major_name = $("#major_id option:selected").text();
                var engage_type = $("#engage_type").val();
                var human_amount = $("#human_amount").val();
                var deadline = $("#deadline").val();
                var register = $("#register").val();
                var regist_time = $("#regist_time").val();
                var major_describe = $("#major_describe").val();
                var engage_required = $("#engage_required").val();


                if (first_kind_name == "") {
                    alert('请选择I级机构下拉框！！！');
                    return false;
                } else if (second_kind_name == "") {
                    alert('请选择II级机构下拉框！！！');
                    return false;
                } else if (third_kind_name == "") {
                    alert('请请选择III级机构下拉框！！！');
                    return false;
                } else if (major_kind_name == "") {
                    alert('请选择职位分类下拉框！！！');
                    return false;
                } else if (major_name == "") {
                    alert('请选择职位名称！！！');
                    return false;
                } else if (engage_type == "") {
                    alert('请选择招聘类型！！！');
                    return false;
                } else if (human_amount == "") {
                    alert('请输入招聘人数！！！');
                    return false;
                } else if (deadline == "") {
                    alert('请输入截止日期！！！');
                    return false;
                } else if (register == "") {
                    alert('请输入登记人！！！');
                    return false;
                } else if (regist_time == "") {
                    alert('请输入登记时间！！！');
                    return false;
                } else if (major_describe == "") {
                    alert('请输入职位描述！！！');
                    return false;
                } else if (engage_required == "") {
                    alert('请输入招聘要求！！！');
                    return false;
                }
                $.ajax({
                    url: "/position/position_register",
                    type: "Post",
                    data: $("#form1").serialize(),
                    success: function (msg) {
                        if (msg > 0) {
                            alert('新增成功!');
                            window.location.href = '/position/position_release_search';
                        } else {
                            alert('新增失败!');
                            window.location.href = '/position/position_release_search';
                        }
                    }
                })
            }
        },
        mounted: function () {
            this.load();
        }
    })
</script>
